package org.gwtrpc4j.test.app.server;

import java.util.Date;

import org.gwtrpc4j.test.app.client.ExceptionGTO;
import org.gwtrpc4j.test.app.client.GreetingService;
import org.gwtrpc4j.test.app.client.MultiParamsGTO;
import org.gwtrpc4j.test.app.client.RequestGTO;
import org.gwtrpc4j.test.app.client.ResponseGTO;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
		GreetingService {

	public String greetServer(String input) {
		// just for test the session cookie

		return "Hello, " + input + "!<br><br>I am running. newSession:"
				+ getThreadLocalRequest().getSession().isNew();
	}

	@Override
	public ResponseGTO greetServer(RequestGTO req) throws ExceptionGTO {
		ResponseGTO r = new ResponseGTO();
		r.now = new Date();
		r.title = "titre";
		return r;
	}

	@Override
	public MultiParamsGTO echoMultiParam(MultiParamsGTO req)
			throws ExceptionGTO {

		return req;
	}
}
